﻿using com.fmtx.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using com.fmtx.IDal;

namespace com.fmtx.Dal
{
    public class OAuthUserServer:BaseServer<OAuthUser>,IOAuthUser
    {
        public new bool Add(OAuthUser bean)
        {
            var has= db.Get(w => w.Uid == bean.Uid && w.Type == bean.Type);
            if (has == null || has.Id == 0)
            {
                return base.Add(bean);
            }
            else {
                throw new Exception("已经绑定了第三方账号！");
            }
        }
        public OAuthUser Get(string openid, OAuthType type)
        {
            return db.Get(w => w.OpenId == openid && w.Type == type);
        }


        public IList<OAuthUser> Query(int uid)
        {
            return db.AllList(w => w.Uid == uid).ToList();
        }
    }
}
